<template>
  <div class="form-container">
    <el-form inline :model="form" ref="refForm" class="form-line" label-width="90">
      <el-form-item label="姓名/手机号" prop="fullName">
        <el-input size="default" @keydown.enter="getList" v-model="form.fullName" placeholder="姓名/手机号"></el-input>
      </el-form-item>
    </el-form>
    <div class="btn-container">
      <el-button type="primary" @click="handleRest(refForm as FormInstance)">重置</el-button>
      <el-button type="primary" @click="getList">查询</el-button>
      <el-button type="primary" @click="handleGo">添加取货员</el-button>
    </div>
  </div>
  <div class="form-container">
    <Tags :info="0" />
  </div>
  <div class="table-container">
    <el-table
      border
      :cell-style="{ textAlign: 'center', fontSize: '13px' }"
      :header-cell-style="{
        textAlign: 'center',
        fontWeight: '100',
        fontSize: '13px',
        color: 'white',
        backgroundColor: '#009688'
      }"
      style="width: 100%"
      :data="dataList"
    >
      <el-table-column fixed prop="fullName" label="姓名" />
      <el-table-column prop="phonenumber" label="手机号" />
      <el-table-column prop="createTime" label="创建时间" />
      <el-table-column fixed="right" label="操作">
        <template #default="">
          <span>--</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination background size="small" layout="prev, pager, next" @change="getList" :total="pageTotal" :page-size="10" />
    </div>
  </div>
</template>

<script setup lang="tsx" name="useProTable">
import { ElMessage, FormInstance } from "element-plus";
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import Tags from "./tags.vue";
import { getPickerListAPI } from "@/api/modules/city/cityPicker/api";
import { Picker } from "@/api/interface/city/cityPicker";
const router = useRouter();
let pageTotal = ref<number>(0);

const form = ref<Picker.StatusParams>({
  fullName: "",
  auditStatus: "0",
  phonenumber: "",
  province: JSON.parse(localStorage.getItem("userInfo") as string).province,
  city: JSON.parse(localStorage.getItem("userInfo") as string).city,
  pageNum: 1,
  pageSize: 10
});
const refForm = ref<FormInstance>();
const dataList = ref<Picker.Row[]>([]);
const handleRest = (formEl: FormInstance) => {
  formEl.resetFields();
  getList();
};
const handleGo = () => {
  router.push({ path: "/cityLevel/cityOrganization/cityPicker/add" });
};
const getList = async () => {
  const { rows, code, msg, total } = await getPickerListAPI(form.value);
  if (code == "200" && rows) {
    dataList.value = rows;
    if (total) {
      pageTotal.value = total;
    }
  } else {
    ElMessage.error(`获取失败,${msg}`);
  }
};
onMounted(() => {
  getList();
});
</script>
<style lang="scss" scoped>
.form-container {
  padding: 10px;
  margin-bottom: 10px;
  background-color: white;
  .btn-container {
    display: inline-block;
    float: right;
    vertical-align: middle;
    ::v-deep .el-button > span {
      font-size: 13px;
    }
  }
  .el-form {
    display: inline-block;
    ::v-deep .el-form-item__label {
      font-size: 13px;
    }
  }
  .form-line {
    .el-form-item {
      margin: 0;
      margin-right: 20px;
    }
    .el-input {
      width: 240px;
    }
    .el-select {
      width: 240px;
    }
  }
}
.table-container {
  padding: 40px 10px;
  padding-bottom: 60px;
  background-color: white;
  .pagination-container {
    // display: inline-block;
    float: right;
    margin-top: 20px;
    background-color: white;
  }
}
::v-deep .el-tag--dark {
  margin: 5px;
  cursor: pointer;
}
::v-deep .el-input--suffix .el-input__inner {
  padding-right: 15px;
}
::v-deep .el-form-item__label {
  font-size: 13px;
  font-weight: 100;
  color: black;
}
::v-deep .el-button > span {
  font-size: 13px;
}
::v-deep .el-input__inner {
  font-size: 13px;
}
</style>
